1. Technical Field
The present invention relates to data processing and, in particular, to monitoring application components. Still more particularly, the present invention provides a method, apparatus, and program product for using bytecode insertion to modify a class definition to define and use probes for application components.
2. Description of Related Art
Binary modification is a language-independent technique for changing programs. A binary modification tool reads a binary program, analyzes the program, modifies the program, and creates a new binary program that is ready for execution. The modification can range from inserting profiling code, optimizing the code, translating the code to a new architecture, etc. The binary modification method works on machine language instructions and is, therefore, programming language independent.
With binary modification, instrumentation of binaries basically involves inserting instructions in the binary program, requiring relocation of data and code. In order to do this, one must be able to disassemble the program into basic blocks and control flow graphs. This requires a sophisticated analysis of the binary code, often requiring an enormous amount of resources, both in time and space. Moreover, in order to be able to modify a binary program, one should know exactly what the program is doing. Without extra information about the binary (e.g., the compiler that generated the binary), it can be very hard to recognize data in code, code in data, and constructs such as user-level context switches, self-modifying code, hand-written assembly language, etc.
Just-in-time instrumentation (JITI) offers a solution to program modification that allows probes to be instrumented dynamically at class load time. JITI is a tool that uses byte code insertion to associate probes to customer applications. Probes are software agents that are used to gather information about the application while it is running. In JITI, probes are linked to parts of the application by locations and associations. Locations determine what part of the application is probed. Associations determine what probes are used at a given location. JITI, for example, uses a dynamic registry to map associations to locations on a per-invocation basis.
A probed class will load a hook for each method being probed. All objects associated with the probe will be instantiated each time the hook is invoked at run time. Furthermore, method probe context objects are created and a parameter list is calculated whether the probe is actually invoked or not. Thus, a drawback of JITI is that it is inefficient due to redundant and sometimes unnecessary computations that perform dynamic object creations and context preparation.